import request from '@/utils/request'

export function getRoutes() {
  return request({
    url: '/routes',
    method: 'get'
  })
}

export function getRoles() {
  return request({
    url: '/role/getInfoList',
    method: 'get'
  })
}

export function getRole() {
  return request({
    url: '/role/getInfo',
    method: 'get'
  })
}

export function addRole(data) {
  return request({
    url: '/role',
    method: 'post',
    data
  })
}

export function updateRole(id, data) {
  return request({
    url: `/role/${id}`,
    method: 'put',
    data
  })
}

export function deleteRole(roleId) {
  return request({
    url: '/role/deleteRole',
    method: 'POST',
    params: { roleId: roleId }
  })
}

export function checkRegistered(roleName) {
  return request({
    url: '/role/getIsRegistered',
    method: 'GET',
    params: { roleName: roleName }
  })
}

export function addOrUpdateRole(data) {
  return request({
    url: '/role/addOrUpdateRole',
    method: 'POST',
    data: data
  })
}
